import React from 'react';
import PureSalaryRefTable from './PureSalaryRefTable.js';
import useSalaryData from './useSalaryData';

const SalaryRefTable = React.forwardRef((props, ref) => {
    const {
        positionCode, // 职位code
        initialData,
        selectCity
    } = props;
    const { dataSource, targetCity, loading } = useSalaryData({ positionCode, ready: !initialData });
    const salaryData = initialData?.dataSource || dataSource;
    const originCityList = initialData?.targetCity || targetCity;
    const cityList = Array.isArray(originCityList) ? originCityList : [originCityList];
    return (
        <PureSalaryRefTable
            ref={ref}
            loading={loading}
            cityList={cityList}
            salaryData={salaryData}
            selectCity={selectCity}
            positionCode={positionCode}
        />
    );
});
SalaryRefTable.displayName = 'SalaryRefTable';

export default SalaryRefTable;
